package ltd.hxya.novel.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ltd.hxya.novel.admin.entity.OperLog;
import ltd.hxya.novel.admin.service.IOperLogService;
import ltd.hxya.novel.common.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/operlog")
public class OperLogController {
    @Autowired
    private IOperLogService operLogService;
    //查询操作状态
    @GetMapping("/list")
    public Result<Page<OperLog>> list(OperLog operLog){
        Page<OperLog> operLogPage = operLogService.operlogPageList(operLog);
        return Result.success(operLogPage);
    }

    //删除日志信息
    @DeleteMapping("/deleteLogs")
    public Result deleteLogs(String[] ids){
        //operLogService.deleteLogs(ids);
        operLogService.deleteLogs(ids);
        return Result.success();
    }

    //清空日志信息
    @DeleteMapping("/clearLog")
    public Result clearLog(){
        operLogService.getBaseMapper().delete(null);
        return Result.success();
    }

}
